package com.shrct.businessprocess.project.impl;

import com.shrct.businessprocess.project.RCProject;
import com.shrct.businessprocess.project.RCProjectEvent;
import com.shrct.businessprocess.project.impl.RCProjectImpl;
import com.shrct.businessprocess.project.proxy.RCProjectEventProxy;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("RCPROJECTEVENT_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rcprojectevent")
public class RCProjectEventImpl extends BaseModelObject implements RCProjectEvent {
  public RCProjectEventImpl() {
    super();
  }
  
  public RCProjectEventImpl(final RCProject project) {
    super();
    this.project = project;
  }
  
  @JoinColumn(name = "project_id")
  @ManyToOne(targetEntity = RCProjectImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCProject project;
  
  public RCProject getProject() {
    return this.project;
  }
  
  public RCProjectEvent setProject(final RCProject project) {
    this.project = project;
    return this;			
    
  }
  
  private Date date;
  
  public Date getDate() {
    return this.date;
  }
  
  public RCProjectEvent setDate(final Date date) {
    this.date = date;
    return this;			
    
  }
  
  private String description;
  
  public String getDescription() {
    return this.description;
  }
  
  public RCProjectEvent setDescription(final String description) {
    this.description = description;
    return this;			
    
  }
  
  public static RCProjectEvent create(final RCProject project, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.project.RCProjectEvent rCProjectEvent = new com.shrct.businessprocess.project.impl.RCProjectEventImpl(
    	project
    );
    objectFactory.create(rCProjectEvent);
    return rCProjectEvent;			
    
  }
  
  public static RCProjectEvent createRCProjectEventImpl(final RCProject project, final IObjectFactory objectFactory, final Procedure1<RCProjectEvent> init) {
    com.shrct.businessprocess.project.RCProjectEvent rCProjectEvent = new com.shrct.businessprocess.project.impl.RCProjectEventImpl(
    	project
    );
    objectFactory.create(rCProjectEvent);
    init.apply(rCProjectEvent);
    
    return rCProjectEvent;			
    
  }
  
  public RCProjectEventProxy toProxy() {
    com.shrct.businessprocess.project.proxy.RCProjectEventProxy proxy = new com.shrct.businessprocess.project.proxy.RCProjectEventProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
